package com.ludomancy.hugealien;

import java.awt.Graphics;
import java.awt.Rectangle;
import com.ludomancy.gamelib.ImageAnimation;
import com.ludomancy.gamelib.Sound;
import com.ludomancy.gamelib.Utils;

public class Suicide extends BasicEntity
{
	private ImageAnimation captureImage;
	private float velocity;
	public Soul soul;
	
	public Suicide(int x, int y, Soul soul)
	{
		this.x = x;
		this.y = y;
		this.soul = soul;
		captureImage = ImageAnimation.create("captured.png", 15, 7, 2);
		captureImage.looping = true;
		captureImage.play();
	}
	
	public Rectangle area()
	{
		return new Rectangle(x-captureImage.strip.frameWidth/2, y, captureImage.strip.frameWidth, captureImage.strip.frameHeight);
	}
	
	public void paint(Graphics g, int px, int py)
	{
		captureImage.paintCurrentFrame(g, px, py, Utils.ANCHOR_HCENTER);
	}
	
	public void update()
	{
		captureImage.update();
		velocity = 2.0f;
		y += velocity;
		if(area().y > Game.WORLD_HEIGHT)
		{
			// die!
			Game.game.city.addStar(new Star(null, null, Star.TYPE_PURPLE));
			Game.game.city.entities.remove(this);
			Sound.play("thud.wav");
		}
	}
}
